<script>
export default {
  components: {},
  data () {
    return {
      radio: 0,
      activeName: '1',
    };
  },
  computed: {
    isButtonDisabled() {
      return this.radio === 0;
    }
  },
  methods: {
    check(radio) {
      console.log(radio)
      if (radio === 3) {
        this.$message.success('恭喜你，答对啦！')
      } else {
        this.$message.error('很遗憾，答错啦！')
      }
    },
  }
}
</script>

<template>
  <div>
    <div>
      <h1 align="center">1.2 Linux基础</h1>
      <el-divider></el-divider>

      <h1>基础常用命令：</h1><br>
      <pre style="margin-left: 2em;"><i class="fa fa-copy"></i><ol class="linenums"><li class="L0"><code class="lang-text"><span class="pln">ls                  </span><span class="pun">用来显示目标列表</span></code></li><li class="L1"><code class="lang-text"></code></li><li class="L2"><code class="lang-text"><span class="pln">cd </span><span class="pun">[</span><span class="pln">path</span><span class="pun">]</span><span class="pln">           </span><span class="pun">用来切换工作目录</span></code></li><li class="L3"><code class="lang-text"></code></li><li class="L4"><code class="lang-text"><span class="pln">pwd                 </span><span class="pun">以绝对路径的方式显示用户当前工作目录</span></code></li><li class="L5"><code class="lang-text"></code></li><li class="L6"><code class="lang-text"><span class="pln">man </span><span class="pun">[</span><span class="pln">command</span><span class="pun">]</span><span class="pln">       </span><span class="pun">查看</span><span class="typ">Linux</span><span class="pun">中的指令帮助、配置文件帮助和编程帮助等信息</span></code></li><li class="L7"><code class="lang-text"></code></li><li class="L8"><code class="lang-text"><span class="pln">apropos </span><span class="pun">[</span><span class="pln">whatever</span><span class="pun">]</span><span class="pln">  </span><span class="pun">在一些特定的包含系统命令的简短描述的数据库文件里查找关键字</span></code></li><li class="L9"><code class="lang-text"></code></li><li class="L0"><code class="lang-text"><span class="pln">echo </span><span class="pun">[</span><span class="kwd">string</span><span class="pun">]</span><span class="pln">       </span><span class="pun">打印一行文本，参数“-</span><span class="pln">e</span><span class="pun">”可激活转义字符</span></code></li><li class="L1"><code class="lang-text"></code></li><li class="L2"><code class="lang-text"><span class="pln">cat </span><span class="pun">[</span><span class="pln">file</span><span class="pun">]</span><span class="pln">          </span><span class="pun">连接文件并打印到标准输出设备上</span></code></li><li class="L3"><code class="lang-text"></code></li><li class="L4"><code class="lang-text"><span class="pln">less </span><span class="pun">[</span><span class="pln">file</span><span class="pun">]</span><span class="pln">         </span><span class="pun">允许用户向前或向后浏览文字档案的内容</span></code></li><li class="L5"><code class="lang-text"></code></li><li class="L6"><code class="lang-text"><span class="pln">mv </span><span class="pun">[</span><span class="pln">file1</span><span class="pun">]</span><span class="pln"> </span><span class="pun">[</span><span class="pln">file2</span><span class="pun">]</span><span class="pln">  </span><span class="pun">用来对文件或目录重新命名，或者将文件从一个目录移到另一个目录中</span></code></li><li class="L7"><code class="lang-text"></code></li><li class="L8"><code class="lang-text"><span class="pln">cp </span><span class="pun">[</span><span class="pln">file1</span><span class="pun">]</span><span class="pln"> </span><span class="pun">[</span><span class="pln">file2</span><span class="pun">]</span><span class="pln">  </span><span class="pun">用来将一个或多个源文件或者目录复制到指定的目的文件或目录</span></code></li><li class="L9"><code class="lang-text"></code></li><li class="L0"><code class="lang-text"><span class="pln">rm </span><span class="pun">[</span><span class="pln">file</span><span class="pun">]</span><span class="pln">           </span><span class="pun">可以删除一个目录中的一个或多个文件或目录，也可以将某个目录及其下属的所有文件及其子目录均删除掉</span></code></li><li class="L1"><code class="lang-text"></code></li><li class="L2"><code class="lang-text"><span class="pln">ps                  </span><span class="pun">用于报告当前系统的进程状态</span></code></li><li class="L3"><code class="lang-text"></code></li><li class="L4"><code class="lang-text"><span class="pln">top                 </span><span class="pun">实时查看系统的整体运行情况</span></code></li><li class="L5"><code class="lang-text"></code></li><li class="L6"><code class="lang-text"><span class="pln">kill                </span><span class="pun">杀死一个进程</span></code></li><li class="L7"><code class="lang-text"></code></li><li class="L8"><code class="lang-text"><span class="pln">ifconfig            </span><span class="pun">查看或设置网络设备</span></code></li><li class="L9"><code class="lang-text"></code></li><li class="L0"><code class="lang-text"><span class="pln">ping                </span><span class="pun">查看网络上的主机是否工作</span></code></li><li class="L1"><code class="lang-text"></code></li><li class="L2"><code class="lang-text"><span class="pln">netstat             </span><span class="pun">显示网络连接、路由表和网络接口信息</span></code></li><li class="L3"><code class="lang-text"></code></li><li class="L4"><code class="lang-text"><span class="pln">nc</span><span class="pun">(</span><span class="pln">netcat</span><span class="pun">)</span><span class="pln">          </span><span class="pun">建立</span><span class="pln"> TCP </span><span class="pun">和</span><span class="pln"> UDP </span><span class="pun">连接并监听</span></code></li><li class="L5"><code class="lang-text"></code></li><li class="L6"><code class="lang-text"><span class="pln">su                  </span><span class="pun">切换当前用户身份到其他用户身份</span></code></li><li class="L7"><code class="lang-text"></code></li><li class="L8"><code class="lang-text"><span class="pln">touch </span><span class="pun">[</span><span class="pln">file</span><span class="pun">]</span><span class="pln">        </span><span class="pun">创建新的空文件</span></code></li><li class="L9"><code class="lang-text"></code></li><li class="L0"><code class="lang-text"><span class="pln">mkdir </span><span class="pun">[</span><span class="pln">dir</span><span class="pun">]</span><span class="pln">         </span><span class="pun">创建目录</span></code></li><li class="L1"><code class="lang-text"></code></li><li class="L2"><code class="lang-text"><span class="pln">chmod               </span><span class="pun">变更文件或目录的权限</span></code></li><li class="L3"><code class="lang-text"></code></li><li class="L4"><code class="lang-text"><span class="pln">chown               </span><span class="pun">变更某个文件或目录的所有者和所属组</span></code></li><li class="L5"><code class="lang-text"></code></li><li class="L6"><code class="lang-text"><span class="pln">nano </span><span class="pun">/</span><span class="pln"> vim </span><span class="pun">/</span><span class="pln"> emacs  </span><span class="pun">字符终端的文本编辑器</span></code></li><li class="L7"><code class="lang-text"></code></li><li class="L8"><code class="lang-text"><span class="kwd">exit</span><span class="pln">                </span><span class="pun">退出</span><span class="pln"> shell</span></code></li></ol></pre>
      <pre style="margin-left: 2em;"><i class="fa fa-copy"></i><ol class="linenums"><li class="L0"><code class="lang-text"><span class="pun">管道命令符</span><span class="pln"> </span><span class="str">"|"</span><span class="pln">       </span><span class="pun">将一个命令的标准输出作为另一个命令的标准输入</span></code></li></ol></pre>

      <el-divider></el-divider>

      <b>使用变量：</b>
      <br><br>
      <pre style="margin-left: 2em;"><i class="fa fa-copy"></i><ol class="linenums"><li class="L0"><code class="lang-text"><span class="kwd">var</span><span class="pun">=</span><span class="pln">value         </span><span class="pun">给变量</span><span class="kwd">var</span><span class="pun">赋值</span><span class="pln">value</span></code></li><li class="L1"><code class="lang-text"></code></li><li class="L2"><code class="lang-text"><span class="pln">$var</span><span class="pun">,</span><span class="pln"> $</span><span class="pun">{</span><span class="kwd">var</span><span class="pun">}</span><span class="pln">      </span><span class="pun">取变量的值</span></code></li><li class="L3"><code class="lang-text"></code></li><li class="L4"><code class="lang-text"><span class="str">`cmd`</span><span class="pun">,</span><span class="pln"> $</span><span class="pun">(</span><span class="pln">cmd</span><span class="pun">)</span><span class="pln">     </span><span class="pun">代换标准输出</span></code></li><li class="L5"><code class="lang-text"></code></li><li class="L6"><code class="lang-text"><span class="str">'string'</span><span class="pln">          </span><span class="pun">非替换字符串</span></code></li><li class="L7"><code class="lang-text"></code></li><li class="L8"><code class="lang-text"><span class="str">"string"</span><span class="pln">          </span><span class="pun">可替换字符串</span></code></li></ol></pre>
      <pre style="margin-left: 2em;"><i class="fa fa-copy"></i><ol class="linenums"><li class="L0"><code class="lang-text"><span class="pln">$ </span><span class="kwd">var</span><span class="pun">=</span><span class="str">"test"</span><span class="pun">;</span></code></li><li class="L1"><code class="lang-text"><span class="pln">$ echo $var</span></code></li><li class="L2"><code class="lang-text"><span class="pln">test</span></code></li><li class="L3"><code class="lang-text"><span class="pln">$ echo </span><span class="str">'This is a $var'</span><span class="pun">;</span></code></li><li class="L4"><code class="lang-text"><span class="typ">This</span><span class="pln"> </span><span class="kwd">is</span><span class="pln"> a $var</span></code></li><li class="L5"><code class="lang-text"><span class="pln">$ echo </span><span class="str">"This is a $var"</span><span class="pun">;</span></code></li><li class="L6"><code class="lang-text"><span class="typ">This</span><span class="pln"> </span><span class="kwd">is</span><span class="pln"> a test</span></code></li><li class="L7"><code class="lang-text"></code></li><li class="L8"><code class="lang-text"><span class="pln">$ echo </span><span class="str">`date`</span><span class="pun">;</span></code></li><li class="L9"><code class="lang-text"><span class="lit">2017</span><span class="pun">年</span><span class="pln"> </span><span class="lit">11</span><span class="pun">月</span><span class="pln"> </span><span class="lit">06</span><span class="pun">日</span><span class="pln"> </span><span class="pun">星期一</span><span class="pln"> </span><span class="lit">14</span><span class="pun">:</span><span class="lit">40</span><span class="pun">:</span><span class="lit">07</span><span class="pln"> CST</span></code></li><li class="L0"><code class="lang-text"><span class="pln">$ $</span><span class="pun">(</span><span class="pln">bash</span><span class="pun">)</span></code></li><li class="L1"><code class="lang-text"></code></li><li class="L2"><code class="lang-text"><span class="pln">$ echo $0</span></code></li><li class="L3"><code class="lang-text"><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">bash</span></code></li><li class="L4"><code class="lang-text"><span class="pln">$ $</span><span class="pun">(</span><span class="pln">$0</span><span class="pun">)</span></code></li></ol></pre>

      <el-divider></el-divider>

      <b>Bash 快捷键</b>
      <br><br>
      <pre style="margin-left: 2em;"><i class="fa fa-copy"></i><ol class="linenums"><li class="L0"><code class="lang-text"><span class="typ">Up</span><span class="pun">(</span><span class="typ">Down</span><span class="pun">)</span><span class="pln">          </span><span class="pun">上（下）一条指令</span></code></li><li class="L1"><code class="lang-text"></code></li><li class="L2"><code class="lang-text"><span class="typ">Ctrl</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> c          </span><span class="pun">终止当前进程</span></code></li><li class="L3"><code class="lang-text"></code></li><li class="L4"><code class="lang-text"><span class="typ">Ctrl</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> z          </span><span class="pun">挂起当前进程，使用“</span><span class="pln">fg</span><span class="pun">”可唤醒</span></code></li><li class="L5"><code class="lang-text"></code></li><li class="L6"><code class="lang-text"><span class="typ">Ctrl</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> d          </span><span class="pun">删除光标处的字符</span></code></li><li class="L7"><code class="lang-text"></code></li><li class="L8"><code class="lang-text"><span class="typ">Ctrl</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> l          </span><span class="pun">清屏</span></code></li><li class="L9"><code class="lang-text"></code></li><li class="L0"><code class="lang-text"><span class="typ">Ctrl</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> a          </span><span class="pun">移动到命令行首</span></code></li><li class="L1"><code class="lang-text"></code></li><li class="L2"><code class="lang-text"><span class="typ">Ctrl</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> e          </span><span class="pun">移动到命令行尾</span></code></li><li class="L3"><code class="lang-text"></code></li><li class="L4"><code class="lang-text"><span class="typ">Ctrl</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> b          </span><span class="pun">按单词后移（向左）</span></code></li><li class="L5"><code class="lang-text"></code></li><li class="L6"><code class="lang-text"><span class="typ">Ctrl</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> f          </span><span class="pun">按单词前移（向右）</span></code></li><li class="L7"><code class="lang-text"></code></li><li class="L8"><code class="lang-text"><span class="typ">Ctrl</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="typ">Shift</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> c  </span><span class="pun">复制</span></code></li><li class="L9"><code class="lang-text"></code></li><li class="L0"><code class="lang-text"><span class="typ">Ctrl</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="typ">Shift</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> v  </span><span class="pun">粘贴</span></code></li></ol></pre>

      <el-divider></el-divider>

      <b>根目录结构</b>
      <br><br>
      <pre style="margin-left: 2em;"><i class="fa fa-copy"></i><ol class="linenums"><li class="L0"><code class="lang-text"><span class="pln">$ uname </span><span class="pun">-</span><span class="pln">a</span></code></li><li class="L1"><code class="lang-text"><span class="typ">Linux</span><span class="pln"> manjaro </span><span class="lit">4.11</span><span class="pun">.</span><span class="lit">5</span><span class="pun">-</span><span class="lit">1</span><span class="pun">-</span><span class="pln">ARCH </span><span class="com">#1 SMP PREEMPT Wed Jun 14 16:19:27 CEST 2017 x86_64 GNU/Linux</span></code></li><li class="L2"><code class="lang-text"><span class="pln">$ ls </span><span class="pun">-</span><span class="pln">al </span><span class="pun">/</span></code></li><li class="L3"><code class="lang-text"><span class="pln">drwxr</span><span class="pun">-</span><span class="pln">xr</span><span class="pun">-</span><span class="pln">x  </span><span class="lit">17</span><span class="pln"> root root  </span><span class="lit">4096</span><span class="pln"> </span><span class="typ">Jun</span><span class="pln"> </span><span class="lit">28</span><span class="pln"> </span><span class="lit">20</span><span class="pun">:</span><span class="lit">17</span><span class="pln"> </span><span class="pun">.</span></code></li><li class="L4"><code class="lang-text"><span class="pln">drwxr</span><span class="pun">-</span><span class="pln">xr</span><span class="pun">-</span><span class="pln">x  </span><span class="lit">17</span><span class="pln"> root root  </span><span class="lit">4096</span><span class="pln"> </span><span class="typ">Jun</span><span class="pln"> </span><span class="lit">28</span><span class="pln"> </span><span class="lit">20</span><span class="pun">:</span><span class="lit">17</span><span class="pln"> </span><span class="pun">..</span></code></li><li class="L5"><code class="lang-text"><span class="pln">lrwxrwxrwx   </span><span class="lit">1</span><span class="pln"> root root     </span><span class="lit">7</span><span class="pln"> </span><span class="typ">Jun</span><span class="pln"> </span><span class="lit">21</span><span class="pln"> </span><span class="lit">22</span><span class="pun">:</span><span class="lit">44</span><span class="pln"> bin </span><span class="pun">-&gt;</span><span class="pln"> usr</span><span class="pun">/</span><span class="pln">bin</span></code></li><li class="L6"><code class="lang-text"><span class="pln">drwxr</span><span class="pun">-</span><span class="pln">xr</span><span class="pun">-</span><span class="pln">x   </span><span class="lit">4</span><span class="pln"> root root  </span><span class="lit">4096</span><span class="pln"> </span><span class="typ">Aug</span><span class="pln"> </span><span class="lit">10</span><span class="pln"> </span><span class="lit">22</span><span class="pun">:</span><span class="lit">50</span><span class="pln"> boot</span></code></li><li class="L7"><code class="lang-text"><span class="pln">drwxr</span><span class="pun">-</span><span class="pln">xr</span><span class="pun">-</span><span class="pln">x  </span><span class="lit">20</span><span class="pln"> root root  </span><span class="lit">3140</span><span class="pln"> </span><span class="typ">Aug</span><span class="pln"> </span><span class="lit">11</span><span class="pln"> </span><span class="lit">11</span><span class="pun">:</span><span class="lit">43</span><span class="pln"> dev</span></code></li><li class="L8"><code class="lang-text"><span class="pln">drwxr</span><span class="pun">-</span><span class="pln">xr</span><span class="pun">-</span><span class="pln">x </span><span class="lit">101</span><span class="pln"> root root  </span><span class="lit">4096</span><span class="pln"> </span><span class="typ">Aug</span><span class="pln"> </span><span class="lit">14</span><span class="pln"> </span><span class="lit">13</span><span class="pun">:</span><span class="lit">54</span><span class="pln"> etc</span></code></li><li class="L9"><code class="lang-text"><span class="pln">drwxr</span><span class="pun">-</span><span class="pln">xr</span><span class="pun">-</span><span class="pln">x   </span><span class="lit">3</span><span class="pln"> root root  </span><span class="lit">4096</span><span class="pln"> </span><span class="typ">Apr</span><span class="pln">  </span><span class="lit">8</span><span class="pln"> </span><span class="lit">19</span><span class="pun">:</span><span class="lit">59</span><span class="pln"> home</span></code></li><li class="L0"><code class="lang-text"><span class="pln">lrwxrwxrwx   </span><span class="lit">1</span><span class="pln"> root root     </span><span class="lit">7</span><span class="pln"> </span><span class="typ">Jun</span><span class="pln"> </span><span class="lit">21</span><span class="pln"> </span><span class="lit">22</span><span class="pun">:</span><span class="lit">44</span><span class="pln"> lib </span><span class="pun">-&gt;</span><span class="pln"> usr</span><span class="pun">/</span><span class="pln">lib</span></code></li><li class="L1"><code class="lang-text"><span class="pln">lrwxrwxrwx   </span><span class="lit">1</span><span class="pln"> root root     </span><span class="lit">7</span><span class="pln"> </span><span class="typ">Jun</span><span class="pln"> </span><span class="lit">21</span><span class="pln"> </span><span class="lit">22</span><span class="pun">:</span><span class="lit">44</span><span class="pln"> lib64 </span><span class="pun">-&gt;</span><span class="pln"> usr</span><span class="pun">/</span><span class="pln">lib</span></code></li><li class="L2"><code class="lang-text"><span class="pln">drwx</span><span class="pun">------</span><span class="pln">   </span><span class="lit">2</span><span class="pln"> root root </span><span class="lit">16384</span><span class="pln"> </span><span class="typ">Apr</span><span class="pln">  </span><span class="lit">8</span><span class="pln"> </span><span class="lit">19</span><span class="pun">:</span><span class="lit">55</span><span class="pln"> lost</span><span class="pun">+</span><span class="pln">found</span></code></li><li class="L3"><code class="lang-text"><span class="pln">drwxr</span><span class="pun">-</span><span class="pln">xr</span><span class="pun">-</span><span class="pln">x   </span><span class="lit">2</span><span class="pln"> root root  </span><span class="lit">4096</span><span class="pln"> </span><span class="typ">Oct</span><span class="pln">  </span><span class="lit">1</span><span class="pln">  </span><span class="lit">2015</span><span class="pln"> mnt</span></code></li><li class="L4"><code class="lang-text"><span class="pln">drwxr</span><span class="pun">-</span><span class="pln">xr</span><span class="pun">-</span><span class="pln">x  </span><span class="lit">15</span><span class="pln"> root root  </span><span class="lit">4096</span><span class="pln"> </span><span class="typ">Jul</span><span class="pln"> </span><span class="lit">15</span><span class="pln"> </span><span class="lit">20</span><span class="pun">:</span><span class="lit">10</span><span class="pln"> opt</span></code></li><li class="L5"><code class="lang-text"><span class="pln">dr</span><span class="pun">-</span><span class="pln">xr</span><span class="pun">-</span><span class="pln">xr</span><span class="pun">-</span><span class="pln">x </span><span class="lit">267</span><span class="pln"> root root     </span><span class="lit">0</span><span class="pln"> </span><span class="typ">Aug</span><span class="pln">  </span><span class="lit">3</span><span class="pln"> </span><span class="lit">09</span><span class="pun">:</span><span class="lit">41</span><span class="pln"> proc</span></code></li><li class="L6"><code class="lang-text"><span class="pln">drwxr</span><span class="pun">-</span><span class="pln">x</span><span class="pun">---</span><span class="pln">   </span><span class="lit">9</span><span class="pln"> root root  </span><span class="lit">4096</span><span class="pln"> </span><span class="typ">Jul</span><span class="pln"> </span><span class="lit">22</span><span class="pln"> </span><span class="lit">22</span><span class="pun">:</span><span class="lit">59</span><span class="pln"> root</span></code></li><li class="L7"><code class="lang-text"><span class="pln">drwxr</span><span class="pun">-</span><span class="pln">xr</span><span class="pun">-</span><span class="pln">x  </span><span class="lit">26</span><span class="pln"> root root   </span><span class="lit">660</span><span class="pln"> </span><span class="typ">Aug</span><span class="pln"> </span><span class="lit">14</span><span class="pln"> </span><span class="lit">21</span><span class="pun">:</span><span class="lit">08</span><span class="pln"> run</span></code></li><li class="L8"><code class="lang-text"><span class="pln">lrwxrwxrwx   </span><span class="lit">1</span><span class="pln"> root root     </span><span class="lit">7</span><span class="pln"> </span><span class="typ">Jun</span><span class="pln"> </span><span class="lit">21</span><span class="pln"> </span><span class="lit">22</span><span class="pun">:</span><span class="lit">44</span><span class="pln"> sbin </span><span class="pun">-&gt;</span><span class="pln"> usr</span><span class="pun">/</span><span class="pln">bin</span></code></li><li class="L9"><code class="lang-text"><span class="pln">drwxr</span><span class="pun">-</span><span class="pln">xr</span><span class="pun">-</span><span class="pln">x   </span><span class="lit">4</span><span class="pln"> root root  </span><span class="lit">4096</span><span class="pln"> </span><span class="typ">May</span><span class="pln"> </span><span class="lit">28</span><span class="pln"> </span><span class="lit">22</span><span class="pun">:</span><span class="lit">07</span><span class="pln"> srv</span></code></li><li class="L0"><code class="lang-text"><span class="pln">dr</span><span class="pun">-</span><span class="pln">xr</span><span class="pun">-</span><span class="pln">xr</span><span class="pun">-</span><span class="pln">x  </span><span class="lit">13</span><span class="pln"> root root     </span><span class="lit">0</span><span class="pln"> </span><span class="typ">Aug</span><span class="pln">  </span><span class="lit">3</span><span class="pln"> </span><span class="lit">09</span><span class="pun">:</span><span class="lit">41</span><span class="pln"> sys</span></code></li><li class="L1"><code class="lang-text"><span class="pln">drwxrwxrwt  </span><span class="lit">36</span><span class="pln"> root root  </span><span class="lit">1060</span><span class="pln"> </span><span class="typ">Aug</span><span class="pln"> </span><span class="lit">14</span><span class="pln"> </span><span class="lit">21</span><span class="pun">:</span><span class="lit">27</span><span class="pln"> tmp</span></code></li><li class="L2"><code class="lang-text"><span class="pln">drwxr</span><span class="pun">-</span><span class="pln">xr</span><span class="pun">-</span><span class="pln">x  </span><span class="lit">11</span><span class="pln"> root root  </span><span class="lit">4096</span><span class="pln"> </span><span class="typ">Aug</span><span class="pln"> </span><span class="lit">14</span><span class="pln"> </span><span class="lit">13</span><span class="pun">:</span><span class="lit">54</span><span class="pln"> usr</span></code></li><li class="L3"><code class="lang-text"><span class="pln">drwxr</span><span class="pun">-</span><span class="pln">xr</span><span class="pun">-</span><span class="pln">x  </span><span class="lit">12</span><span class="pln"> root root  </span><span class="lit">4096</span><span class="pln"> </span><span class="typ">Jun</span><span class="pln"> </span><span class="lit">28</span><span class="pln"> </span><span class="lit">20</span><span class="pun">:</span><span class="lit">17</span><span class="pln"> </span><span class="kwd">var</span></code></li></ol></pre>
      <br>
      由于不同的发行版会有略微的不同，我们这里使用的是基于 Arch 的发行版 Manjaro，以上就是根目录下的内容，我们介绍几个重要的目录：
      <ul>
        <li style="margin-left: 2em;">/bin、/sbin：链接到 /usr/bin，存放 Linux 一些核心的二进制文件，其包含的命令可在 shell 上运行。</li>
        <li style="margin-left: 2em;">/boot：操作系统启动时要用到的程序。</li>
        <li style="margin-left: 2em;">/dev：包含了所有 Linux 系统中使用的外部设备。需要注意的是这里并不是存放外部设备的驱动程序，而是一个访问这些设备的端口。</li>
        <li style="margin-left: 2em;">/etc：存放系统管理时要用到的各种配置文件和子目录。</li>
        <li style="margin-left: 2em;">/etc/rc.d：存放 Linux 启动和关闭时要用到的脚本。</li>
        <li style="margin-left: 2em;">/home：普通用户的主目录。</li>
        <li style="margin-left: 2em;">/lib、/lib64：链接到 /usr/lib，存放系统及软件需要的动态链接共享库。</li>
        <li style="margin-left: 2em;">/mnt：这个目录让用户可以临时挂载其他的文件系统。</li>
        <li style="margin-left: 2em;">/proc：虚拟的目录，是系统内存的映射。可直接访问这个目录来获取系统信息。</li>
        <li style="margin-left: 2em;">/root：系统管理员的主目录。</li>
        <li style="margin-left: 2em;">/srv：存放一些服务启动之后需要提取的数据。</li>
        <li style="margin-left: 2em;">/sys：该目录下安装了一个文件系统 sysfs。该文件系统是内核设备树的一个直观反映。当一个内核对象被创建时，对应的文件和目录也在内核对象子系统中被创建。</li>
        <li style="margin-left: 2em;">/tmp：公用的临时文件存放目录。</li>
        <li style="margin-left: 2em;">/usr：应用程序和文件几乎都在这个目录下。</li>
        <li style="margin-left: 2em;">/usr/src：内核源代码的存放目录。</li>
        <li style="margin-left: 2em;">/var：存放了很多服务的日志信息。</li>
      </ul>
      <el-divider></el-divider>
      <b>进程管理</b><br><br>
      <ul>
        <li style="margin-left: 2em;">
          top
          <ul>
            <li style="margin-left: 2em;">可以实时动态地查看系统的整体运行情况。</li>
        </ul>
        </li>
        <li style="margin-left: 2em;">
          ps
          <ul>
            <li style="margin-left: 2em;">用于报告当前系统的进程状态。可以搭配 kill 指令随时中断、删除不必要的程序。</li>
            <li style="margin-left: 2em;">查看某进程的状态：$ ps -aux | grep [file]，其中返回内容最左边的数字为进程号（PID）。</li>
          </ul>
        </li>
        <li style="margin-left: 2em;">
          kill
          <ul>
            <li style="margin-left: 2em;">用来删除执行中的程序或工作。</li>
            <li style="margin-left: 2em;">删除进程某 PID 指定的进程：$ kill [PID]</li>
          </ul>
        </li>
      </ul>
      <el-divider></el-divider>
      <b>UID 和 GID</b><br><br>
      Linux 是一个支持多用户的操作系统，每个用户都有 User ID(UID) 和 Group ID(GID)，UID 是对一个用户的单一身份标识，而 GID 则对应多个 UID。知道某个用户的 UID 和 GID 是非常有用的，一些程序可能就需要 UID/GID 来运行。可以使用 id 命令来查看：
      <pre style="margin-left: 2em;"><i class="fa fa-copy"></i><ol class="linenums"><li class="L0"><code class="lang-text"><span class="pln">$ id root</span></code></li><li class="L1"><code class="lang-text"><span class="pln">uid</span><span class="pun">=</span><span class="lit">0</span><span class="pun">(</span><span class="pln">root</span><span class="pun">)</span><span class="pln"> gid</span><span class="pun">=</span><span class="lit">0</span><span class="pun">(</span><span class="pln">root</span><span class="pun">)</span><span class="pln"> groups</span><span class="pun">=</span><span class="lit">0</span><span class="pun">(</span><span class="pln">root</span><span class="pun">),</span><span class="lit">1</span><span class="pun">(</span><span class="pln">bin</span><span class="pun">),</span><span class="lit">2</span><span class="pun">(</span><span class="pln">daemon</span><span class="pun">),</span><span class="lit">3</span><span class="pun">(</span><span class="pln">sys</span><span class="pun">),</span><span class="lit">4</span><span class="pun">(</span><span class="pln">adm</span><span class="pun">),</span><span class="lit">6</span><span class="pun">(</span><span class="pln">disk</span><span class="pun">),</span><span class="lit">10</span><span class="pun">(</span><span class="pln">wheel</span><span class="pun">),</span><span class="lit">19</span><span class="pun">(</span><span class="pln">log</span><span class="pun">)</span></code></li><li class="L2"><code class="lang-text"><span class="pln">$ id firmy</span></code></li><li class="L3"><code class="lang-text"><span class="pln">uid</span><span class="pun">=</span><span class="lit">1000</span><span class="pun">(</span><span class="pln">firmy</span><span class="pun">)</span><span class="pln"> gid</span><span class="pun">=</span><span class="lit">1000</span><span class="pun">(</span><span class="pln">firmy</span><span class="pun">)</span><span class="pln"> groups</span><span class="pun">=</span><span class="lit">1000</span><span class="pun">(</span><span class="pln">firmy</span><span class="pun">),</span><span class="lit">3</span><span class="pun">(</span><span class="pln">sys</span><span class="pun">),</span><span class="lit">7</span><span class="pun">(</span><span class="pln">lp</span><span class="pun">),</span><span class="lit">10</span><span class="pun">(</span><span class="pln">wheel</span><span class="pun">),</span><span class="lit">90</span><span class="pun">(</span><span class="pln">network</span><span class="pun">),</span><span class="lit">91</span><span class="pun">(</span><span class="pln">video</span><span class="pun">),</span><span class="lit">93</span><span class="pun">(</span><span class="pln">optical</span><span class="pun">),</span><span class="lit">95</span><span class="pun">(</span><span class="pln">storage</span><span class="pun">),</span><span class="lit">96</span><span class="pun">(</span><span class="pln">scanner</span><span class="pun">),</span><span class="lit">98</span><span class="pun">(</span><span class="pln">power</span><span class="pun">),</span><span class="lit">56</span><span class="pun">(</span><span class="pln">bumblebee</span><span class="pun">)</span></code></li></ol></pre>
      UID 为 0 的 root 用户类似于系统管理员，它具有系统的完全访问权。我自己新建的用户 firmy，其 UID 为 1000，是一个普通用户。GID 的关系存储在 /etc/group 文件中：
      <pre style="margin-left: 2em;"><i class="fa fa-copy"></i><ol class="linenums"><li class="L0"><code class="lang-text"><span class="pln">$ cat </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="kwd">group</span></code></li><li class="L1"><code class="lang-text"><span class="pln">root</span><span class="pun">:</span><span class="pln">x</span><span class="pun">:</span><span class="lit">0</span><span class="pun">:</span><span class="pln">root</span></code></li><li class="L2"><code class="lang-text"><span class="pln">bin</span><span class="pun">:</span><span class="pln">x</span><span class="pun">:</span><span class="lit">1</span><span class="pun">:</span><span class="pln">root</span><span class="pun">,</span><span class="pln">bin</span><span class="pun">,</span><span class="pln">daemon</span></code></li><li class="L3"><code class="lang-text"><span class="pln">daemon</span><span class="pun">:</span><span class="pln">x</span><span class="pun">:</span><span class="lit">2</span><span class="pun">:</span><span class="pln">root</span><span class="pun">,</span><span class="pln">bin</span><span class="pun">,</span><span class="pln">daemon</span></code></li><li class="L4"><code class="lang-text"><span class="pln">sys</span><span class="pun">:</span><span class="pln">x</span><span class="pun">:</span><span class="lit">3</span><span class="pun">:</span><span class="pln">root</span><span class="pun">,</span><span class="pln">bin</span><span class="pun">,</span><span class="pln">firmy</span></code></li><li class="L5"><code class="lang-text"><span class="pun">......</span></code></li></ol></pre>
      所有用户的信息（除了密码）都保存在 /etc/passwd 文件中，而为了安全起见，加密过的用户密码保存在 /etc/shadow 文件中，此文件只有 root 权限可以访问。
      <pre style="margin-left: 2em;"><i class="fa fa-copy"></i><ol class="linenums"><li class="L0"><code class="lang-text"><span class="pln">$ sudo cat </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">shadow</span></code></li><li class="L1"><code class="lang-text"><span class="pln">root</span><span class="pun">:</span><span class="pln">$6$root$wvK</span><span class="pun">.</span><span class="pln">pRXFEH80GYkpiu1tEWYMOueo4tZtq7mYnldiyJBZDMe</span><span class="pun">.</span><span class="pln">mKwt</span><span class="pun">.</span><span class="typ">WIJnehb4bhZchL</span><span class="pun">/</span><span class="lit">93Oe1ok9UwxYf79yR1</span><span class="pun">:</span><span class="lit">17264</span><span class="pun">::::::</span></code></li><li class="L2"><code class="lang-text"><span class="pln">firmy</span><span class="pun">:</span><span class="pln">$6$firmy$dhGT</span><span class="pun">.</span><span class="pln">WP91lnpG5</span><span class="pun">/</span><span class="lit">10GfGdj5L1fFVSoYlxwYHQn</span><span class="pun">.</span><span class="pln">llc5eKOvr7J8nqqGdVFKykMUSDNxix5Vh8zbXIapt0oPd8</span><span class="pun">.:</span><span class="lit">17264</span><span class="pun">:</span><span class="lit">0</span><span class="pun">:</span><span class="lit">99999</span><span class="pun">:</span><span class="lit">7</span><span class="pun">:::</span></code></li></ol></pre>
      由于普通用户的权限比较低，这里使用 sudo 命令可以让普通用户以 root 用户的身份运行某一命令。使用 su 命令则可以切换到一个不同的用户：
      <pre style="margin-left: 2em;"><i class="fa fa-copy"></i><ol class="linenums"><li class="L0"><code class="lang-text"><span class="pln">$ whoami</span></code></li><li class="L1"><code class="lang-text"><span class="pln">firmy</span></code></li><li class="L2"><code class="lang-text"><span class="pln">$ su root</span></code></li><li class="L3"><code class="lang-text"><span class="com"># whoami</span></code></li><li class="L4"><code class="lang-text"><span class="pln">root</span></code></li></ol></pre>
      whoami 用于打印当前有效的用户名称，shell 中普通用户以 $ 开头，root 用户以 # 开头。在输入密码后，我们已经从 firmy 用户转换到 root 用户了。

      <el-divider></el-divider>

      <b>权限设置</b><br><br>
      在　Linux 中，文件或目录权限的控制分别以读取、写入、执行 3 种一般权限来区分，另有 3 种特殊权限可供运用。使用 ls -l [file] 来查看某文件或目录的信息：
      <pre style="margin-left: 2em;"><i class="fa fa-copy"></i><ol class="linenums"><li class="L0"><code class="lang-text"><span class="pln">$ whoami</span></code></li><li class="L1"><code class="lang-text"><span class="pln">firmy</span></code></li><li class="L2"><code class="lang-text"><span class="pln">$ su root</span></code></li><li class="L3"><code class="lang-text"><span class="com"># whoami</span></code></li><li class="L4"><code class="lang-text"><span class="pln">root</span></code></li></ol></pre>
      <pre style="margin-left: 2em;"><i class="fa fa-copy"></i><ol class="linenums"><li class="L0"><code class="lang-text"><span class="pln">$ ls </span><span class="pun">-</span><span class="pln">l </span><span class="pun">/</span></code></li><li class="L1"><code class="lang-text"><span class="pln">lrwxrwxrwx   </span><span class="lit">1</span><span class="pln"> root root     </span><span class="lit">7</span><span class="pln"> </span><span class="typ">Jun</span><span class="pln"> </span><span class="lit">21</span><span class="pln"> </span><span class="lit">22</span><span class="pun">:</span><span class="lit">44</span><span class="pln"> bin </span><span class="pun">-&gt;</span><span class="pln"> usr</span><span class="pun">/</span><span class="pln">bin</span></code></li><li class="L2"><code class="lang-text"><span class="pln">drwxr</span><span class="pun">-</span><span class="pln">xr</span><span class="pun">-</span><span class="pln">x   </span><span class="lit">4</span><span class="pln"> root root  </span><span class="lit">4096</span><span class="pln"> </span><span class="typ">Jul</span><span class="pln"> </span><span class="lit">28</span><span class="pln"> </span><span class="lit">08</span><span class="pun">:</span><span class="lit">48</span><span class="pln"> boot</span></code></li><li class="L3"><code class="lang-text"><span class="pun">-</span><span class="pln">rw</span><span class="pun">-</span><span class="pln">r</span><span class="pun">--</span><span class="pln">r</span><span class="pun">--</span><span class="pln">   </span><span class="lit">1</span><span class="pln"> root root </span><span class="lit">18561</span><span class="pln"> </span><span class="typ">Apr</span><span class="pln">  </span><span class="lit">2</span><span class="pln"> </span><span class="lit">22</span><span class="pun">:</span><span class="lit">48</span><span class="pln"> desktopfs</span><span class="pun">-</span><span class="pln">pkgs</span><span class="pun">.</span><span class="pln">txt</span></code></li></ol></pre>
      第一栏从第二个字母开始就是权限字符串，权限表示三个为一组，依次是所有者权限、组权限、其他人权限。每组的顺序均为 rwx，如果有相应权限，则表示成相应字母，如果不具有相应权限，则用 - 表示。
      <ul>
        <li style="margin-left: 2em;">r：读取权限，数字代号为 “4”</li>
        <li style="margin-left: 2em;">w：写入权限，数字代号为 “2”</li>
        <li style="margin-left: 2em;">x：执行或切换权限，数字代号为 “1”</li>
      </ul>
      通过第一栏的第一个字母可知，第一行是一个链接文件 （l），第二行是个目录（d），第三行是个普通文件（-）。
      用户可以使用 chmod 指令去变更文件与目录的权限。权限范围被指定为所有者（u）、所属组（g）、其他人（o）和所有人（a）。
      <ul>
        <li style="margin-left: 2em;">-R：递归处理，将指令目录下的所有文件及子目录一并处理；</li>
        <li style="margin-left: 2em;">权限范围+权限设置：开启权限范围的文件或目录的该选项权限设置
          <ul>
            <li style="margin-left: 2em;">$ chmod a+r [file]：赋予所有用户读取权限</li>
          </ul>
        </li>
        <li style="margin-left: 2em;">权限范围-权限设置：关闭权限范围的文件或目录的该选项权限设置
          <ul>
            <li style="margin-left: 2em;">$ chmod u-w [file]：取消所有者写入权限</li>
          </ul>
        </li>
        <li style="margin-left: 2em;">权限范围=权限设置：指定权限范围的文件或目录的该选项权限设置；
          <ul>
            <li style="margin-left: 2em;">$ chmod g=x [file]：指定组权限为可执行</li>
            <li style="margin-left: 2em;">$ chmod o=rwx [file]：制定其他人权限为可读、可写和可执行</li>
          </ul>
        </li>
      </ul>
      <el-divider></el-divider>
      <b>调用约定</b><br>
      函数调用约定是对函数调用时如何传递参数的一种约定。关于它的约定有许多种，下面我们分别从内核接口和用户接口介绍 32 位和 64 位 Linux 的调用约定。
      <br><b>内核接口</b><br>
      x86-32 系统调用约定：Linux 系统调用使用寄存器传递参数。eax 为 syscall_number，ebx、ecx、edx、esi、ebp 用于将 6 个参数传递给系统调用。返回值保存在 eax 中。所有其他寄存器（包括 EFLAGS）都保留在 int 0x80 中。<br>
      x86-64 系统调用约定：内核接口使用的寄存器有：rdi、rsi、rdx、r10、r8、r9。系统调用通过 syscall 指令完成。除了 rcx、r11 和 rax，其他的寄存器都被保留。系统调用的编号必须在寄存器 rax 中传递。系统调用的参数限制为 6 个，不直接从堆栈上传递任何参数。返回时，rax 中包含了系统调用的结果。而且只有 INTEGER 或者 MEMORY 类型的值才会被传递给内核。
      <br><b>用户接口</b><br>
      x86-32 函数调用约定：参数通过栈进行传递。最后一个参数第一个被放入栈中，直到所有的参数都放置完毕，然后执行 call 指令。这也是 Linux 上 C 语言函数的方式。
      <br>
      x86-64 函数调用约定：x86-64 下通过寄存器传递参数，这样做比通过栈有更高的效率。它避免了内存中参数的存取和额外的指令。根据参数类型的不同，会使用寄存器或传参方式。如果参数的类型是 MEMORY，则在栈上传递参数。如果类型是 INTEGER，则顺序使用 rdi、rsi、rdx、rcx、r8 和 r9。所以如果有多于 6 个的 INTEGER 参数，则后面的参数在栈上传递。
      <el-divider></el-divider>

      <b>环境变量</b><br>
      环境变量字符串都是 name=value 这样的形式。大多数 name 由大写字母加下画线组成，一般把 name 部分叫做环境变量名，value 部分则是环境变量的值，而且 value 需要以 “/0” 结尾，环境变量定义了该进程的运行环境。
      <b>分类</b>
      <ul>
        <li style="margin-left: 2em;">按照生命周期划分
          <ul>
            <li style="margin-left: 2em;">永久环境变量：修改相关配置文件，永久生效。</li>
            <li style="margin-left: 2em;">临时环境变量：使用 export 命令，在当前终端下生效，关闭终端后失效。</li>
          </ul>
        </li>
        <li style="margin-left: 2em;">按照作用域划分
          <ul>
            <li style="margin-left: 2em;">系统环境变量：对该系统中所有用户生效。</li>
            <li style="margin-left: 2em;">用户环境变量：对特定用户生效。</li>
          </ul>
        </li>
      </ul>
      <el-divider></el-divider>
    </div>
    <div class="bottom-container">
      <h3>下面哪个选项不是Linux进程管理指令？</h3>
      <el-radio-group v-model="radio">
        <el-radio :label="1">top</el-radio>
        <el-radio :label="2">ps</el-radio>
        <el-radio :label="3">ls</el-radio>
        <el-radio :label="4">kill</el-radio>
        <el-button type="primary" plain :disabled="isButtonDisabled" @click="check(radio)">检查</el-button>
      </el-radio-group>
    </div>
    <el-divider></el-divider>

  </div>
</template>

<style scoped>

</style>